
void dump_symtab_32(Elf32_Sym* p, char* p_str_tab)
{

}

void dump_symtab_64(FILE* fp, Elf64_Shdr* psh64, int e_shnum)
{
	int i, j, v, count;
	Elf64_Sym* p;
	void* vp, *vp_it;
	char* p_str_tab;
	for(i = 0; i < e_shnum; i++)
	{
		if(psh64[i].sh_type != 2)
			continue;
		/*read symbol string table*/
		p_str_tab = mmap(NULL, psh64[psh64[i].sh_link].sh_size, PROT_READ | PROT_WRITE,
                MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
		fseek(fp, psh64[psh64[i].sh_link].sh_offset, SEEK_SET);
		fread(p_str_tab, psh64[psh64[i].sh_link].sh_size, 1, fp);

		vp_it = vp = mmap(NULL, psh64[i].sh_size, PROT_READ | PROT_WRITE,
                MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
		fseek(fp, psh64[i].sh_offset, SEEK_SET);
		//fread(p, psh64[i].sh_size, 1, fp);//this bug causing pointer overran is fixed by valgrind
		fread(vp, psh64[i].sh_size, 1, fp);

		count = j = 0;
		printf("Dumping symbal table: section index %d\n\n", i);
		while(count < psh64[i].sh_size)
		{
			p = (Elf64_Sym*)vp_it;
			printf("-------------------------\nSymbol Index %d\n", j++);
			printf("st_name:\t%s\n", &p_str_tab[p->st_name]);
			printf("st_value:\t%lX\n", p->st_value);
			printf("st_size:\t%ld\n", p->st_size);
			printf("st_info:\t%d\n", p->st_info);
			v = ELF32_ST_BIND(p->st_info);
			switch(v)
			{
				case 0:
					printf("  ELF64_ST_BIND:\t%d => STB_LOCAL\n", v);
					break;
				case 1:
					printf("  ELF64_ST_BIND:\t%d => STB_GLOBAL\n", v);
					break;
				case 2:
					printf("  ELF64_ST_BIND:\t%d => STB_WEAK\n", v);
					break;
				default:
					if(v >= 13 && v <= 15)
					{
						printf("  ELF64_ST_BIND:\t%d => STB_PROC\n", v);
					}
					else
					{
						printf("  ELF64_ST_BIND:\t%d\n", v);
					}
					break;
			}
			v = ELF32_ST_TYPE(p->st_info);
			switch(v)
			{
				case 0:
					printf("  ELF64_ST_TYPE:\t%d => STT_NOTYPE\n", v);
					break;
				case 1:
					printf("  ELF64_ST_TYPE:\t%d => STT_OBJECT\n", v);
					break;
				case 2:
					printf("  ELF64_ST_TYPE:\t%d => STT_FUNC\n", v);
					break;
				case 3:
					printf("  ELF64_ST_TYPE:\t%d => STT_SECTION\n", v);
					break;
				case 4:
					printf("  ELF64_ST_TYPE:\t%d => STT_FILE\n", v);
					break;
				default:
					if(v >= 13 && v <= 15)
					{
						printf("  ELF64_ST_TYPE:\t%d => STT_PROC\n", v);
					}
					else
					{
						printf("  ELF64_ST_TYPE:\t%d\n", v);
					}
					break;
			}
			printf("st_other:\t%d\n", p->st_other);
			printf("st_shndx:\t%d\n", p->st_shndx);
			vp_it = align_ptr(p + 1, psh64[i].sh_addralign);
			count += (int)(vp_it - (void *)p);
		}

		munmap(vp, psh64[i].sh_size);
		munmap(p_str_tab, psh64[psh64[i].sh_link].sh_size);
	}
}
